package partie2;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    
    private ServerSocket serverSocket;
    private int port;
    
    public Server(int port) 
    {
        this.port = port;
    }
    
    public void start() throws IOException 
    {
        System.out.println("Starting the socket server at port:" + port);
        serverSocket = new ServerSocket(port);
        
        while(true)
        {
            Socket client = serverSocket.accept();
            
            (new ReceivingRequest(client)).start();    
        }
    }
    
    public static void main(String[] args)
    {
        int portNumber = 1500;
        
        try 
        {
            // initializing the server
            Server Server = new Server(portNumber);
            Server.start();
        } 
        catch (IOException e) 
        {
            System.out.println(e.toString());
        }
    }
}
